package com.firefly.admin.monitor.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.firefly.admin.common.vo.Result;
import com.firefly.admin.monitor.entity.FyMonitorErrorOperationLog;
import com.firefly.admin.monitor.entity.FyMonitorOperationLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.firefly.admin.monitor.service.FyMonitorOperationLogService;
import com.firefly.admin.monitor.vo.MonitorOperateLogQueryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Api(tags = "系统日志接口API")
@RestController
@RequestMapping("/monitor/operate/log")
public class FyMonitorOperationLogController {
    @Autowired
    private FyMonitorOperationLogService fyMonitorOperationLogService;

    /**
     * 分页查询系统日志接口
     *
     * @param monitorOperateLogQueryVo 分页查询参数
     * @return 分页列表
     */
    @ApiOperation(value = "分页查询系统日志接口", notes = "分页查询系统日志接口", httpMethod = "GET")
    @PreAuthorize(value = "hasAuthority('monitor:operation:log')")
    @GetMapping("/list")
    public Result<Page<FyMonitorOperationLog>> getMonitorOperateLogList(MonitorOperateLogQueryVo monitorOperateLogQueryVo) {
        return fyMonitorOperationLogService.getMonitorOperateLogList(monitorOperateLogQueryVo);
    }

    /**
     * 分页查询系统错误日志接口
     *
     * @param monitorOperateLogQueryVo 分页查询参数
     * @return 分页列表
     */
    @ApiOperation(value = "分页查询系统错误日志接口", notes = "分页查询系统错误日志接口", httpMethod = "GET")
    @PreAuthorize(value = "hasAuthority('monitor:error:operation:log')")
    @GetMapping("/error/list")
    public Result<Page<FyMonitorErrorOperationLog>> getMonitorErrorOperateLogList(MonitorOperateLogQueryVo monitorOperateLogQueryVo) {
        return fyMonitorOperationLogService.getMonitorErrorOperateLogList(monitorOperateLogQueryVo);
    }

    /**
     * 查询日志页面枚举下拉选接口
     *
     * @return 查询结果
     */
    @ApiOperation(value = "查询日志页面枚举下拉选接口", notes = "查询日志页面枚举下拉选接口", httpMethod = "GET")
    @GetMapping("/select/enum")
    public Result<Map<String, Object>> getOperateLogSelectEnum() {
        return fyMonitorOperationLogService.getOperateLogSelectEnum();
    }
}
